<template>
	<view></view>
</template>

<script>
	export default {
		data() {
			return {
				scode:''
			}
		},
		created() {
			uni.redirectTo({
				url: '/pages/user/login/login?type=my&scode=11'
				})
		
			var dd= new Date('2021-10-25 11:22:09');
			var d2=	dd.getDate();
			console.log(d2);
		var d1=	dd.getHours();
			console.log(d1);
			setInterval(10000);
			
			var dd1= Date.now();
			console.log(dd1);
		var tt=	dd1 - dd;
			console.log(tt);
			let t = parseInt(tt);
			if(t <= 6600000)
			{
				console.log('123');
				}else
				{
					console.log('456');
			uni.navigateTo({
				url: '/pages/user/login/login?type=my&scode=11'
				})
				}
			return;
			let scode = this.$route.query.scode;
			this.scode = scode;
			let that = this;
			// let openid = uni.getStorageSync("openid");
		    let openid="oklcX67Bog5HB6AhCFoGr5yO2R1A"
			if(openid)
			{
				let date = uni.getStorageSync("LoginDate");
				if(date){
				if(Date.now()-date <= 6600000)
				{
					uni.setNavigationBarTitle({ title:'登录中' });
					that.getdata();
				}
				else
				{
					uni.navigateTo({
						url: '/pages/user/login/login?type=device&scode='+scode
					})
				}
				}else
				{
					uni.navigateTo({
						url: '/pages/user/login/login?type=device&scode='+scode
					})
				}
			}
			else
			{
				that.getWeiXin();
			}
		},
		methods:{
			getWeiXin() {
				//微信授权跳转
				window.location.href = 'http://evcssappapi.yushengkeji.cn/user/v1/getweixincode'
			},
			//判断是否正在充电
			ischaring(){
				let that=this;
				that.http.tokenreq({
					url: 'user/v1/chargingstatus',
				}).then((res) => {
				
					let e=res.data;
					let cinfo = e.data;
					let navData = JSON.stringify(cinfo); // 这里转换成 字符串
					if(e.code==0 && e.success){
						uni.navigateTo({
							url: '/pages/user/charging/chargingnow?cinfo='+ navData
						})
						return;
					}else{
						that.getdata();
					}
				})
			},
			getdata(){
			    let that = this;
				that.http.tokenreq({
					url: 'user/v1/getdinfo',
					data: {
						"equipment_number": that.scode,
					}
				}).then((res) => {
					let e = res.data
					if (e.code == 0 && e.success) {
					let info=e.data;
					let navData = JSON.stringify(info); 
				
					uni.navigateTo({
					 	url: '/pages/user/pay/pay?scode='+that.scode+'&dinfo='+navData
					 })
					} else {
						setTimeout(function () {
							uni.showToast({
								icon: 'none',
								title: e.message
							});
						    uni.hideLoading();
							
						}, 1000);
					}
				})
			}
		}
	}
</script>

<style>
</style>
